Dashboard Temp Share Shortlinks Frames API

HTMLify

Number of Valid Parentheses.py
Views: 33 | Author: prakhardoneria
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
import math

class Solution:
    def findWays(self, n):
        if n % 2 != 0:
            return 0
        
        k = n // 2
        
        ans = math.comb(2 * k, k) // (k + 1)
        return ans